package com.zy.config.service.impl;

import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zy.config.convertor.ConfigConvertor;
import com.zy.config.dto.AppConfigDetailsDto;
import com.zy.config.dto.AppConfigDetailsQueryDto;
import com.zy.config.entity.AppConfigDetails;
import com.zy.config.mapper.AppConfigDetailsMapper;
import com.zy.config.service.AppConfigDetailsService;
import com.zy.db.utils.QueryUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zy
 * @description:
 * @since 2023/3/18 23:06
 */
@Service
public class AppConfigDetailsServiceimpl extends ServiceImpl<AppConfigDetailsMapper, AppConfigDetails> implements AppConfigDetailsService {

    @Override
    public List<AppConfigDetailsDto> list(AppConfigDetailsQueryDto dto) {
        QueryWrapper queryWrapper = QueryUtils.getParam(new QueryWrapper<AppConfigDetails>(), dto, AppConfigDetailsQueryDto.class);
        List<AppConfigDetails> list = this.list(queryWrapper);
        return ConfigConvertor.INSTANCE.toListDto(list);
    }

    @Override
    public List<AppConfigDetailsDto> getDetails(Long configId) {
        return this.list(new AppConfigDetailsQueryDto(configId, null));
    }

}
